﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Windows8Accelerator.Core.Xaml.Caching
{
    public class CachedObject
    {
        public object Object { get; set; }
        public DateTime CacheDate { get; set; }
    }

    public class CachedObject<T>
    {
        public CachedObject(ObjectOrigin origin)
        {
            Origin = origin;
        }

        public CachedObject(CachedObject cachedObject, ObjectOrigin origin)
            : this(origin)
        {
            CacheDate = cachedObject.CacheDate;
            Object = (T)cachedObject.Object;
        }

        public CachedObject(Exception exception)
        {
            Exception = exception;
            Origin = ObjectOrigin.Error;
        }

        public Exception Exception { get; set; }
        public ObjectOrigin Origin { get; private set; }
        public DateTime CacheDate { get; private set; }
        public T Object { get; private set; }
    }
}
